Skip to content

Fix/usage timezone handling#3086

Closed
IamCoder18 wants to merge 3 commits into
Kilo-Org:mainfrom
IamCoder18:fix/usage-timezone-handling
Closed

Fix/usage timezone handling#3086
IamCoder18 wants to merge 3 commits into
Kilo-Org:mainfrom
IamCoder18:fix/usage-timezone-handling

Conversation

@IamCoder18
Copy link
Copy Markdown

@IamCoder18 IamCoder18 commented May 7, 2026

Summary

Fix timezone handling in the usage tab so dates are grouped by the user's local timezone instead of UTC. This affects "By Day", "By Model & Day" views, streak calculation, and streak calendar.

Closes #3085

Changes:

  • API route /api/profile/usage now accepts timeZone parameter and uses PostgreSQL AT TIME ZONE for timezone-aware date grouping
  • Client detects browser timezone via Intl.DateTimeFormat().resolvedOptions().timeZone
  • Streak calculation and calendar data generation now use toLocaleDateString('en-CA', { timeZone }) for correct local date formatting
  • Initial timezone state is null to defer query until browser timezone is detected

Visual Changes

N/A - functionality fix, dates now correctly reflect user's local timezone.

Reviewer Notes

  • The en-CA locale is used because it formats dates as YYYY-MM-DD by default
  • Added isValidTimezone() function to validate IANA timezone strings and prevent SQL injection
  • API falls back to UTC if invalid or missing timezone parameter

Comment thread apps/web/src/app/api/profile/usage/route.ts Outdated
Comment thread apps/web/src/app/(app)/usage/page.tsx Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 7, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • apps/web/src/app/(app)/usage/page.tsx
  • apps/web/src/app/api/profile/usage/route.ts

Reviewed by gpt-5.5-20260423 · 310,160 tokens

@catrielmuller
Copy link
Copy Markdown
Contributor

Hi @IamCoder18 ! I hope you're doing well. I'm excited to let you know that I just released the new version of the Usage dashboard, and it includes a fix to ensure all dates are in UTC. I’d love to hear your thoughts about the new dashboard! Thanks for your collaboration!

@IamCoder18
Copy link
Copy Markdown
Author

Hi! The usage dashboard actually isn't working for me. It doesn't show any data.

image

But I'm sure that with the data loading issue fixed, the new usage dashboard would be great for tracking usage.

@catrielmuller
Copy link
Copy Markdown
Contributor

Hi! The usage dashboard actually isn't working for me. It doesn't show any data.

image But I'm sure that with the data loading issue fixed, the new usage dashboard would be great for tracking usage.

If you could send me a direct message on Discord or an email with your account details, that would be awesome! I’d love to help you figure out what’s going on. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(usage): Usage tab displays dates in UTC instead of user's local timezone

2 participants